package com.bbx.flink.demo.socket_text;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class SocketTextDemo {

//    public static void  main(String [] args) throws Exception {
//        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//        DataStreamSource<String> stringDataStreamSource = env.socketTextStream("192.168.10.131", 10003,",");
//        stringDataStreamSource.print();
//        env.execute("SocketTextDemo");
//    }


    public  static  void main(String [] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<String> source  = env.socketTextStream("192.168.10.131", 10003);
        source.map(new MapFunction<String, Integer>() {
            @Override
            public Integer map(String value) throws Exception {
                int i = Integer.parseInt(value);
                return i*2;
            }

            private static final long serialVersionUID = -3611020617418043672L;
        }).print();



        env.execute();
    }






}

